return _gtk_css_image_cross_fade_new (start, end, progress);
}
-static void
-gtk_css_image_real_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
-{
- GtkSnapshot snapshot;
- GskRenderNode *node;
- cairo_region_t *clip;
-
- clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height });
- gtk_snapshot_init (&snapshot, NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
- gtk_css_image_snapshot (image, &snapshot, width, height);
- node = gtk_snapshot_finish (&snapshot);
-
- if (node != NULL)
- {
- gsk_render_node_draw (node, cr);
- gsk_render_node_unref (node);
- }
-
- cairo_region_destroy (clip);
-}
-
-static void
-gtk_css_image_real_snapshot (GtkCssImage *image,
- GtkSnapshot *snapshot,
- double width,
- double height)
-{
- cairo_t *cr;
-
- cr = gtk_snapshot_append_cairo (snapshot,
- &GRAPHENE_RECT_INIT (0, 0, width, height),
- "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
- _gtk_css_image_draw (image, cr, width, height);
- cairo_destroy (cr);
-}
-
static void
_gtk_css_image_class_init (GtkCssImageClass *klass)
{
klass->compute = gtk_css_image_real_compute;
klass->equal = gtk_css_image_real_equal;
klass->transition = gtk_css_image_real_transition;
- klass->draw = gtk_css_image_real_draw;
- klass->snapshot = gtk_css_image_real_snapshot;
}
static void
double width,
double height)
{
- GtkCssImageClass *klass;
+ GtkSnapshot snapshot;
+ GskRenderNode *node;
+ cairo_region_t *clip;
g_return_if_fail (GTK_IS_CSS_IMAGE (image));
g_return_if_fail (cr != NULL);
cairo_save (cr);
- klass = GTK_CSS_IMAGE_GET_CLASS (image);
+ clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height });
+ gtk_snapshot_init (&snapshot, NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
+ gtk_css_image_snapshot (image, &snapshot, width, height);
+ node = gtk_snapshot_finish (&snapshot);
+
+ if (node != NULL)
+ {
+ gsk_render_node_draw (node, cr);
+ gsk_render_node_unref (node);
+ }
- klass->draw (image, cr, width, height);
+ cairo_region_destroy (clip);
cairo_restore (cr);
}
}
static void
-gtk_css_image_builtin_real_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_builtin_real_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
/* It's a builtin image, other code will draw things */
}
GtkCssImageClass *image_class = GTK_CSS_IMAGE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- image_class->draw = gtk_css_image_builtin_real_draw;
+ image_class->snapshot = gtk_css_image_builtin_real_snapshot;
image_class->parse = gtk_css_image_builtin_parse;
image_class->print = gtk_css_image_builtin_print;
image_class->compute = gtk_css_image_builtin_compute;
double progress);
/* draw to 0,0 with the given width and height */
- void (* draw) (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height);
void (* snapshot) (GtkCssImage *image,
GtkSnapshot *snapshot,
double width,
}
static void
-gtk_css_image_radial_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_radial_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
cairo_pattern_t *pattern;
double r1, r2, r3, r4, r;
double offset;
int i, last;
+ cairo_t *cr;
+
+ cr = gtk_snapshot_append_cairo (snapshot,
+ &GRAPHENE_RECT_INIT (0, 0, width, height),
+ "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
x = _gtk_css_position_value_get_x (radial->position, width);
y = _gtk_css_position_value_get_y (radial->position, height);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
+
+ cairo_destroy (cr);
}
static gboolean
GtkCssImageClass *image_class = GTK_CSS_IMAGE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- image_class->draw = gtk_css_image_radial_draw;
+ image_class->snapshot = gtk_css_image_radial_snapshot;
image_class->parse = gtk_css_image_radial_parse;
image_class->print = gtk_css_image_radial_print;
image_class->compute = gtk_css_image_radial_compute;
G_DEFINE_TYPE (GtkCssImageWin32, _gtk_css_image_win32, GTK_TYPE_CSS_IMAGE)
static void
-gtk_css_image_win32_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_win32_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageWin32 *wimage = GTK_CSS_IMAGE_WIN32 (image);
cairo_surface_t *surface;
int dx, dy;
+ cairo_t *cr;
+
+ cr = gtk_snapshot_append_cairo (snapshot,
+ &GRAPHENE_RECT_INIT (0, 0, width, height),
+ "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
surface = gtk_win32_theme_create_surface (wimage->theme, wimage->part, wimage->state, wimage->margins,
width, height, &dx, &dy);
cairo_fill (cr);
cairo_surface_destroy (surface);
+
+ cairo_destroy (cr);
}
static gboolean
object_class->finalize = gtk_css_image_win32_finalize;
- image_class->draw = gtk_css_image_win32_draw;
+ image_class->snapshot = gtk_css_image_win32_snapshot;
image_class->parse = gtk_css_image_win32_parse;
image_class->print = gtk_css_image_win32_print;
}